package com.example.boos.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import com.example.boos.context.BossInfo;
import com.example.boos.util.MyRabbitUtil;

public class RabbitService extends Service {
    public RabbitService() {

    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.e("服务测试","开启服务");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.e("服务测试","StartCommand");
        MyRabbitUtil.run =  true;
        String exchange = "Bossorders";
        String routeKey = "store:"+ BossInfo.currentStoreId;
        Log.e("服务测试","routeKey:"+routeKey);
        MyRabbitUtil.handlerMessage(exchange,routeKey);
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        MyRabbitUtil.run = false;
        Log.e("服务测试","服务销毁");
        super.onDestroy();
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }
}